//
//  HeaderOneCollectionReusableView.m
//  ToWhere
//
//  Created by dllo on 15/11/13.
//  Copyright © 2015年 www.TE.com. All rights reserved.
//

#import "HeaderOneCollectionReusableView.h"

#define kWidth [UIScreen mainScreen].bounds.size.width / 375
#define kHeight [UIScreen mainScreen].bounds.size.height / 667

@implementation HeaderOneCollectionReusableView

-(void)dealloc
{
    [_viewOne release];
    [_viewTwo release];
    [_view release];
    [_labelTwo release];
    [_strOne release];
    [_strTwo release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame
{
    self= [super initWithFrame:frame];
    if (self) {
        
      //  创建视图
        [self createView];
    }
    return self;
}
#pragma mark 创建视图
-(void)createView
{
    self.view = [[UIView alloc]init];
    self.view.backgroundColor = [UIColor colorWithWhite:0.927 alpha:1.000];
    [self addSubview:self.view];
    [_view release];
    
    
    self.labelTwo = [[UILabel alloc]init];
   // self.labelTwo.backgroundColor = [UIColor redColor];
    self.labelTwo.textColor = [UIColor grayColor];
    
    [self addSubview:self.labelTwo];
    [_labelTwo release];
    
    self.viewOne = [[UIView alloc]init];
    self.viewOne.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:self.viewOne];
    [_viewOne release];
    
    self.viewTwo = [[UIView alloc]init];
    self.viewTwo.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:self.viewTwo];
    [_viewTwo release];

}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    self.view.frame = CGRectMake(0, 0, 375 * kWidth, 10 * kHeight);
    
    CGRect authorRect = [self.labelTwo.text boundingRectWithSize:CGSizeMake(375, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObjectsAndKeys:self.labelTwo.font,NSFontAttributeName, nil] context:nil];
    self.labelTwo.frame = CGRectMake(0, 10*kHeight, authorRect.size.width, 30 *kHeight);
    self.labelTwo.center = CGPointMake(375 / 2 * kWidth, 25 * kHeight);
    
    self.viewOne.frame = CGRectMake(0, 25 * kHeight - 1 * kHeight, (375 * kWidth - self.labelTwo.frame.size.width) / 2 - 10 * kWidth, 1 * kHeight);
    self.viewTwo.frame = CGRectMake((375 * kHeight + self.labelTwo.frame.size.width) / 2 + 10 * kWidth, self.viewOne.frame.origin.y, self.viewOne.frame.size.width, self.viewOne.frame.size.height);
    
    
}


-(void)setStrTwo:(NSString *)strTwo
{
    if (_strTwo != strTwo) {
        [_strTwo release];
        _strTwo = [strTwo retain];
    }
    
    self.labelTwo.text = strTwo;
    self.labelTwo.font = [UIFont fontWithName:@"Helvetica-Bold" size:20 * kWidth];
    self.labelTwo.textAlignment = NSTextAlignmentCenter;
}


@end
